<template>
	<div class="addProject business-workAdd">
		<div class=" back_contain">
			<div class="btn_flex">
				<div @click="handleClick(1,flag)" :class="flag? 'disabled' :'active'">呼 叫</div>
				<div @click="handleClick(2,true)" class="active">发 车</div>
			</div>
		</div>
	</div>
</template>
<script>

	export default {
		props: ['uuid','type'],
		data() {
			return {
				flag:true,
				refreshInterval:null,
			}
		},
		methods: {
			handleClick(type,bol){
				if(type == 1){
					if(bol){
						return;
					}
					this.$emit('agvCall',this.uuid)
				}else{
					this.$emit('agvSend',this.uuid)
				}
			},
			getAgvPoint(){
				let self = this;
				
				self.$http({
					url: "/jinl/plan/getAgvPoint",
					method: "post",
					params:{}
				}).then(resp => {
					if (resp.success) {
						if(resp.result&&resp.result.point){
							self.flag = true;
						}else {
							self.flag = false;
						}
					}
				})
			},
			startAutoRefresh() {
                this.refreshInterval = setInterval(() => {
                    this.getAgvPoint();
                }, 10000); 
            },
            stopAutoRefresh() {
                // 清除定时器
                if (this.refreshInterval) {
                    clearInterval(this.refreshInterval);
                    this.refreshInterval = null;
                }
            },
		},

		watch: {
			

		},

		mounted() {
			this.getAgvPoint();
			this.startAutoRefresh();
		},
		beforeDestroy() {
		  this.stopAutoRefresh();
		},
		
		
	}
</script>
<style lang="scss" scoped>
	@import "@/style/dialog.scss";

	.flex_ {
		width: 150px;

		._left {
			color: #9e9e9e;
		}
	}

	.nav_list {
		margin-top: 20px;

		._title {
			line-height: 40px;
			color: #00D1D0;
			display: flex;
			justify-content: space-between;

			i {
				font-size: 16px;
				margin-right: 5px;
			}
		}

		.edit_ {
			color: #409EFF;
			cursor: pointer;
		}
	}

	.back_contain {
		width: 100%;
		height: 100%;
		margin-top: 20px;
		/* position: relative; */
	}

	.btn_flex {
		/* width: 50%;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%); */
		display: flex;
		justify-content: space-evenly;
		.disabled {
			cursor: not-allowed;
			/* pointer-events: none; */
		}

		div {
			width: 150px;
			height: 50px;
			font-size: 30px;
			text-align: center;
			cursor: pointer;
			border-radius: 10px;
			color: #eee;
			line-height: 50px;
			font-weight: bold;
			background-color: #0193DE;
			/* margin-right: 50px; */
		}

		div:hover {
			background-color: #139de2;
		}
	}
</style>